<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<ul class="nav nav-tabs">
    <li <?php  if($op=='list' ) { ?> class="active" <?php  } ?>>
        <a href="<?php  echo $this->createWebUrl('user', array('op' => 'list'));?>">用户列表</a>
    </li>
	<?php  if($op=='zt' ) { ?>
	<li class="active">
        <a href="#">直推用户列表</a>
    </li>
	<?php  } ?>
	<?php  if($op=='jt' ) { ?>
	<li class="active">
        <a href="#">间推用户列表</a>
    </li>
	<?php  } ?>
	<?php  if($op=='post' ) { ?>
	<li class="active">
        <a href="#">用户信息修改</a>
    </li>
	<?php  } ?>
</ul>
<?php 
if($op == 'list' || $op == 'zt' || $op == 'jt' ){
?>
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="<?php  echo $this->modulename?>" />
				<input type="hidden" name="do" value="user" />
				

				<div class="form-group">
				    <label class="col-xs-12 col-sm-1 control-label" style="width: 5%;">注册日期</label>
					<div class="col-sm-2 col-xs-12" style="width: 15%;"><?php  echo tpl_form_field_daterange('daterange', $daterange)?></div>
					<label class="col-xs-12 col-sm-1 control-label" style="width: 8%;">昵称/会员号</label>
					<div class="col-sm-2 col-xs-12" style="width: 18%;">
						<input class="form-control" name="keyword2" id="" type="text" value="<?php  echo $_GPC['keyword2'];?>" placeholder="根据用户昵称/会员号搜索">
					</div>
					<label class="col-xs-12 col-sm-1 control-label" style="width: 5%;">等级</label>
					<div class="col-sm-2 col-xs-12" style="width: 15%;">
                        <select name="keyword1" class="form-control">
						    <option value="9" >全部</option>
                            <option value="99" ><?php  echo $settings['member_name'];?></option>
							 <option value="1" ><?php  echo $settings['tuan_name'];?></option>
                            <option value="2" ><?php  echo $settings['he_name'];?></option>
                        </select>
                    </div>
					<div>
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button type="button" class="btn btn-default">总记录数：<?php  echo $total;?></button>
					</div>
				</div>
			</form>
		</div>
</div>

<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
    <div style="padding:15px;">
        <table class="table table-hover table-condensed">
            <thead class="navbar-inner">
                <tr>
                    <tr>

                    <th>id</th>

                    <th>上级</th>

                    <th>昵称</th>

					<th>openid</th>

					<?php  if($settings['system_type'] == 1) { ?><th>unionid</th><?php  } ?>

                    <th>会员号</th>

					<th>直推人数</th>

					<th>间推人数</th>

					<th>余额</th>

					<th>积分</th>

                    <th>类型</th>

                    <th>注册时间</th>

                    <th>修改为</th>

                    <th style="text-align:right;">操作</th>

                </tr>
            </thead>
                <tbody id="level-list">

                <?php  if(is_array($list)) { foreach($list as $item) { ?>
				<?php 
				    $p_user = array();
					$user_ztall = array();
					$user_jtall = array();
				    if($settings['system_type'] == 1){
					    $p_user = pdo_get($this->modulename . "_user_u", array("uid" => $item['parent_id'],'system_id' => $settings['system_id']));
						$user_ztall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user_u") . " WHERE system_id = ".$settings['system_id']." and parent_id = ".$item['uid']);
						$user_jtall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user_u") . " WHERE system_id = ".$settings['system_id']." and parent_id != ".$item['uid']." and invite_uid like '%_".$item['uid']."%'");
					}else{
					    $p_user = pdo_get($this->modulename . "_user", array("uid" => $item['parent_id'],'uniacid' => $_W['uniacid']));
						$user_ztall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user") . " WHERE uniacid = ".$_W['uniacid']." and parent_id = ".$item['uid']);
						$user_jtall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user") . " WHERE uniacid = ".$_W['uniacid']." and parent_id != ".$item['uid']." and invite_uid like '%_".$item['uid']."%'");
					}
				?>

                <tr>

                    <td><div class="type-parent"><?php  echo $item['user_id'];?></div></td>

                    <td>

                        <?php  if(!empty($p_user['avatar'])) { ?>

                        <img style="width: 40px;" src="<?php  echo $p_user['avatar'];?>">

                        <?php  } ?>

                        <?php  echo $p_user['nickname'];?>

                    </td>

                    <td>

                        <img style="width: 40px;" src="<?php  echo $item['avatar'];?>">

                        <?php  echo $item['nickname'];?>

                    </td>

					<td>

                        <?php  echo substr($item['openid'], -10)?>

                    </td>

					<?php  if($settings['system_type'] == 1) { ?>
					<td>

                        <?php  echo substr($item['unionid'], -10)?>

                    </td>
					<?php  } ?>

					<td>

                        <?php  echo $item['uid'];?>

                    </td>

					<td>

                        <a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('uid'=>$item['uid'],'op'=>'zt'))?>" title="个人订单"><?php  echo $user_ztall[0]['num'];?></a>

                    </td>

					<td>

                        <a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('uid'=>$item['uid'],'op'=>'jt'))?>" title="个人订单"><?php  echo $user_jtall[0]['num'];?></a>

                    </td>

					<td>

                        <?php  echo $item['money'];?>

                    </td>

					<td>

                        <?php  echo $item['credit'];?>

                    </td>

                    <td>

                        <div class="type-parent">

                            <?php  if($item['is_tuan']==0) { ?>

                                <span class="label label-primary"><?php  echo $settings['member_name'];?></span>

                            <?php  } else if($item['is_tuan']==1) { ?>
							    <span class="label label-primary"><?php  echo $settings['tuan_name'];?></span>

                            <?php  } else if($item['is_tuan']==2) { ?>
							    <span class="label label-primary"><?php  echo $settings['he_name'];?></span>

                            <?php  } ?>

                        </div>

                    </td>

                    <td><div class="type-parent"><?php  echo date('Y-m-d H:i:s',$item['create_time'])?></div></td>

                    <td>

                        <?php  if($item['is_tuan']==0) { ?>
                            <a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'tuan','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['tuan_name'];?>？');return false;" title="设为<?php  echo $settings['tuan_name'];?>"><?php  echo $settings['tuan_name'];?></a>
							<a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'he','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['he_name'];?>？');return false;" title="设为<?php  echo $settings['he_name'];?>"><?php  echo $settings['he_name'];?></a>

                        <?php  } else if($item['is_tuan']==1) { ?>
						    <a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'putong','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['member_name'];?>？');return false;" title="设为<?php  echo $settings['member_name'];?>"><?php  echo $settings['member_name'];?></a>
							<a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'he','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['he_name'];?>？');return false;" title="设为<?php  echo $settings['he_name'];?>"><?php  echo $settings['he_name'];?></a>

                        <?php  } else if($item['is_tuan']==2) { ?>
                            <a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'putong','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['member_name'];?>？');return false;" title="设为<?php  echo $settings['member_name'];?>"><?php  echo $settings['member_name'];?></a>
							<a class="btn btn-primary btn-sm" href="<?php  echo $this->createWebUrl('user',array('op'=>'tuan','user_id'=>$item['user_id']))?>" onclick="return confirm('确认设为<?php  echo $settings['tuan_name'];?>？');return false;" title="设为<?php  echo $settings['tuan_name'];?>"><?php  echo $settings['tuan_name'];?></a>

                        <?php  } ?>

                    </td>

                    <td style="text-align:right;">
					    <a class="btn btn-default btn-sm" href="<?php  echo $this->createWebUrl('order_user',array('uid'=>$item['uid'],'opp'=>'user'))?>" title="个人订单">个人订单</a>
						<a class="btn btn-default btn-sm" href="<?php  echo $this->createWebUrl('order_user',array('uid'=>$item['uid'],'opp'=>'team'))?>" title="团队订单">团队订单</a>
						<a href="<?php  echo $this->createWebUrl('user', array('op' => 'post', 'user_id' => $item['user_id']))?>" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
                        <a class="btn btn-default btn-sm"   href="<?php  echo $this->createWebUrl('user',array('op'=>del,'user_id'=>$item['user_id']))?>" onclick="return confirm('确认删除此用户吗？');return false;" title="删除">删除</a>

                    </td>

                </tr>
                <?php  } } ?>
            </tbody>
        </table>
        <?php  echo $pager;?>
    </div>
</form>
<?php 
}elseif($op == 'post'){
?>

<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="<?php  echo $adv['id'];?>" />
		<div class="panel panel-default">
			<div class="panel-heading">
				用户信息修改
			</div>
			<div class="panel-body">
			    <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户UID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="<?php  echo $user['uid'];?>" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">openid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="<?php  echo $user['openid'];?>" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">unionid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="<?php  echo $user['unionid'];?>" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">昵称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[nickname]" class="form-control" value="<?php  echo $user['nickname'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">会员等级：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="0" <?php  if($user['is_tuan'] == 0) { ?>checked="true"<?php  } ?> /> <?php  echo $settings['member_name'];?></label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="1" <?php  if($user['is_tuan'] == 1) { ?>checked="true"<?php  } ?> /> <?php  echo $settings['tuan_name'];?></label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="2" <?php  if($user['is_tuan'] == 2) { ?>checked="true"<?php  } ?> /> <?php  echo $settings['he_name'];?></label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">上级UID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[parent_id]" class="form-control" value="<?php  echo $user['parent_id'];?>" />
						<span class="help-block" style="color:red;">*如果要修改上级，下面的邀请关系也要做相应修改</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">邀请关系</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[invite_uid]" class="form-control" value="<?php  echo $user['invite_uid'];?>" />
						<span class="help-block" style="color:red;">*格式：0_间属上级UID_直属上级UID，例如：0_16801234_16801235_16801236</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">积分</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[credit]" class="form-control" value="<?php  echo $user['credit'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">余额</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[money]" class="form-control" value="<?php  echo $user['money'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[realname]" class="form-control" value="<?php  echo $user['realname'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[mobile]" class="form-control" value="<?php  echo $user['mobile'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付宝账号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[alipayno]" class="form-control" value="<?php  echo $user['alipayno'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否新用户：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[new]" value="0" <?php  if($user['new'] == 0) { ?>checked="true"<?php  } ?> /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[new]" value="1" <?php  if($user['new'] == 1) { ?>checked="true"<?php  } ?> /> 是</label>
						<span class="help-block" style="color:red;">*用于计算拉新任务。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否电影票管理员：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[movie_ticketer]" value="0" <?php  if($user['movie_ticketer'] == 0) { ?>checked="true"<?php  } ?> /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[movie_ticketer]" value="1" <?php  if($user['movie_ticketer'] == 1) { ?>checked="true"<?php  } ?> /> 是</label>
						<span class="help-block" style="color:red;">*用于电影票报价通知。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否黑名单：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[is_black]" value="0" <?php  if($user['is_black'] == 0) { ?>checked="true"<?php  } ?> /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_black]" value="1" <?php  if($user['is_black'] == 1) { ?>checked="true"<?php  } ?> /> 是</label>
					</div>
				</div>
				
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
		</div>
	</form>
</div>


<?php 
}
?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>
